package view_stunden;

import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.util.Observable;
import java.util.Observer;

import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.SwingUtilities;
import javax.swing.table.TableColumn;

import model.StundenModel;

import controller.StundenController;

public class Tagesansicht extends JPanel implements Observer {

	private StundenController stundenController;
	private StundenModel stundenModel;

	private MyActionListener myActionListener;
	private MyMouseListener myMouseListener;

	private JTable table;
	private JScrollPane scrollPane;
	private TableColumn col;

	/**
	 * Konstruktor
	 * 
	 * @param stundenController
	 * @param stundenModel
	 */
	public Tagesansicht(StundenController stundenController,
			StundenModel stundenModel) {
		super();

		this.stundenController = stundenController;
		this.stundenModel = stundenModel;

		this.stundenModel.addObserver(this);

		initTable();
		
		addWidgets();
	}

	/**
	 * 
	 */
	private void addWidgets() {
		add(BorderLayout.CENTER, scrollPane);
		
	}

	/**
	 * 
	 */
	private void initTable() {
		table = new JTable(stundenModel);

		table.getTableHeader()
				.setFont(new Font(Font.SANS_SERIF, Font.BOLD, 12));

		table.setRowHeight(20);
		table.setFont(new Font(Font.SANS_SERIF, Font.PLAIN, 10));
		table.addMouseListener(myMouseListener);

		table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);

		scrollPane = new JScrollPane(table);

		col = table.getColumnModel().getColumn(0);
		col.setPreferredWidth(100);

		col = table.getColumnModel().getColumn(1);
		col.setPreferredWidth(100);

		col = table.getColumnModel().getColumn(2);
		col.setPreferredWidth(100);
		
		col = table.getColumnModel().getColumn(3);
		col.setPreferredWidth(100);
		
		col = table.getColumnModel().getColumn(4);
		col.setPreferredWidth(100);
		
		scrollPane.setPreferredSize(new Dimension(502,500));
	}

	@Override
	public void update(Observable arg0, Object arg1) {
		// TODO Auto-generated method stub

	}

	/**
	 * 
	 * @author Schweingruber Roger
	 * 
	 */
	private class MyActionListener implements ActionListener {

		@Override
		public void actionPerformed(ActionEvent arg0) {

		}

	}

	/**
	 * 
	 * @author Schweingruber Roger
	 * 
	 */
	private class MyMouseListener implements MouseListener {

		@Override
		public void mouseClicked(MouseEvent arg0) {
			// TODO Auto-generated method stub

		}

		@Override
		public void mouseEntered(MouseEvent arg0) {
			// TODO Auto-generated method stub

		}

		@Override
		public void mouseExited(MouseEvent arg0) {
			// TODO Auto-generated method stub

		}

		@Override
		public void mousePressed(MouseEvent arg0) {

			// Maus in der Tabelle
			if (arg0.getSource().equals(table)) {

			}
		}

		@Override
		public void mouseReleased(MouseEvent arg0) {
			// TODO Auto-generated method stub

		}

	}
}
